<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>规则集管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		
		
	function deleteRule(id){
	      if(!isUseRuleSet(id)){
	    	  alert("规则集正在使用不能删除!")
	    	  return false;
	      }
		
	    if(confirm("确定要删除规则集吗？")){
	    	 window.location.href="${ctx}/rule/aegisRuleSet/audit?id="+id+"&status=04&branchId=${branchId}";
	      }
		
	} 
				
     function  isUseRuleSet(id){
	      var isExist = false;
	      
	      //同步方法调用  判断规则集是否在使用
		  $.ajax({
			    type: "POST",
			    url: "${ctx}/rule/aegisRuleSet/isUseRuleSet",
			    data: {id:id},
			    dataType: "json",
			    async:false, 
			    success: function(data){
			    	  if(data){
			    		isExist=true;
			    	  }else{
			    		isExist=false;
			    	 }
			   }
	
           })
        return isExist;
     }
		
		
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/rule/aegisRuleSet/">规则集列表</a></li>
		<shiro:hasPermission name="rule:aegisRuleSet:edit"><li><a href="${ctx}/rule/aegisRuleSet/form?branchId=${branchId}">规则集添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="aegisRuleSet" action="${ctx}/rule/aegisRuleSet?branchId=${branchId}" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<ul class="ul-form">
			<li><label>规则集名称：</label>
				<form:input path="rulesetname" htmlEscape="false" maxlength="20" class="input-medium"/>
			</li>
			<li><label>每页：</label>
			<select id="pageSize" name="pageSize" class="input-medium">
			    <option value="20"    <c:choose><c:when test="${page.pageSize=='20'}">selected=true</c:when></c:choose>>20</option>
				<option value="30"    <c:choose><c:when test="${page.pageSize=='30'}">selected=true</c:when></c:choose>>30</option>
				<option value="100"   <c:choose><c:when test="${page.pageSize=='100'}">selected=true</c:when></c:choose>>100</option>
				<option value="500"   <c:choose><c:when test="${page.pageSize=='500'}">selected=true</c:when></c:choose>>500</option>
				<option value="1000"  <c:choose><c:when test="${page.pageSize=='1000'}">selected=true</c:when></c:choose>>1000</option>
			</select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th	style="color:#5599FF;">id</th>
				<th	style="color:#5599FF;">规则集名称</th>
				<th	style="color:#5599FF;">业务类型</th>
				<th	style="color:#5599FF;">子集关系</th>
				<th	style="color:#5599FF;">状态</th>
				<th	style="color:#5599FF;">录入人</th>
				<th	style="color:#5599FF;">创建时间</th>
				<shiro:hasPermission name="rule:aegisRuleSet:edit"><th style="color:#5599FF;">操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="aegisRuleSet">
			<tr>
				<td>
					${aegisRuleSet.id}
				</a></td>
				<td>
					${aegisRuleSet.rulesetname}
				</td>
				<td>
					<c:if test="${aegisRuleSet.businesstype==1}">金币业务</c:if>
					<c:if test="${aegisRuleSet.businesstype==2}">其他业务</c:if>
				</td>
				<td>
					<c:if test="${aegisRuleSet.relation==1}">或者</c:if>
					<c:if test="${aegisRuleSet.relation==2}">并且</c:if>
				</td>
				<td>
				    <c:if test="${aegisRuleSet.status eq '00'}">审核中</c:if>
					<c:if test="${aegisRuleSet.status eq '01'}">审核成功</c:if>
					<c:if test="${aegisRuleSet.status eq '02'}">打回</c:if>
					<c:if test="${aegisRuleSet.status eq '03'}">作废</c:if>
				</td>
				<td>
					${aegisRuleSet.inputMan}
				</td>
				<td>
					<fmt:formatDate value="${aegisRuleSet.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="rule:aegisRuleSet:edit"><td>
				  <c:if test="${aegisRuleSet.status eq '00'}">
    				<a href="${ctx}/rule/aegisRuleSet/info?branchId=${branchId}&id=${aegisRuleSet.id}&mark=2">审核</a>
					<a href="${ctx}/rule/aegisRuleSet/info?branchId=${branchId}&id=${aegisRuleSet.id}&mark=1">查看</a>
				  </c:if>
				  <c:if test="${aegisRuleSet.status eq '01'}">
					<a href="${ctx}/rule/aegisRuleSet/info?branchId=${branchId}&id=${aegisRuleSet.id}&mark=1">查看</a>
					<a href="javascript:void(0);"  onclick="deleteRule('${aegisRuleSet.id}')">删除</a>
				  </c:if>
				  <c:if test="${aegisRuleSet.status eq '02'}">
					<a href="${ctx}/rule/aegisRuleSet/form?branchId=${branchId}&id=${aegisRuleSet.id}">修改</a>
					<a href="${ctx}/rule/aegisRuleSet/info?branchId=${branchId}&id=${aegisRuleSet.id}&mark=1">查看</a>
				  </c:if>
				   <c:if test="${aegisRuleSet.status eq '03'}">
					<a href="${ctx}/rule/aegisRuleSet/info?branchId=${branchId}&id=${aegisRuleSet.id}&mark=1">查看</a>
				  </c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>